package com.example.shop_2211.adapter

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.ExplosiveMoney
import com.example.shop_2211.R

class MoneyAdapter:BaseQuickAdapter<ExplosiveMoney,BaseViewHolder>(R.layout.item_money) {
    var selectType = 4//设置选中的type
    override fun convert(holder: BaseViewHolder, item: ExplosiveMoney) {
        holder.setText(R.id.money_tv,item.name)
        if(item.type.toInt()==selectType){
            holder.getView<TextView>(R.id.money_tv).setTextColor(Color.RED)
            holder.getView<TextView>(R.id.money_tv).background = ColorDrawable(Color.GREEN)
        }else{
            holder.getView<TextView>(R.id.money_tv).setTextColor(Color.BLACK)
            holder.getView<TextView>(R.id.money_tv).background = ColorDrawable(Color.WHITE)
        }

    }
    fun setType(type:Int){
        selectType = type
        notifyDataSetChanged()//为了让效果展示出来
    }
}